//地图点击查询
var baseUrl='http://10.66.241.217:8080/';
var localBaseUrl = 'localhost:8082/';
const getSpatialCount=(obj,lon_1,lon_3,lat_1,lat_3,lon_2,lat_2,x,y,zoom_p)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: baseUrl + "web/item_list/getSpatialCount", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                getSpatialCount_return  = object.data;
                if (getSpatialCount_return==0){
                    vectorSource.clear();
                    overlay_map_element.setPosition(undefined);
                    app_map.loadingProject.close();
                    return [];
                }
                //第二步select 获取对象所在图层，特定对象Id
                select_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'"}';
                select_p_return = select_p(select_parameter);
                //第三步getSortList 若存在多个对象，获取对象列表
                getSortList_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'"}';
                getSortList_return = getSortList(getSortList_parameter);
                //第四步getSpatialData 再次获取对象信息，信息较为完善
                getSpatialData_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","location":"POLYGON(('+lon_2+' '+lat_1 +','+lon_1+' '+lat_1+','+lon_1+' '+lat_2+','+lon_2+' '+lat_2+','+lon_2+' '+lat_1+'))","elementType":"'+getSpatialCount_return[0].type+'","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'","pageIndex":1,"pageSize":10,"layers":[{"elementType":"irr","index":2},{"elementType":"rvlk","index":3},{"elementType":"rswb","index":3},{"elementType":"ggqd","index":12},{"elementType":"gate","index":22}],"sort":"'+getSortList_return[0].esfiledname+'","order":"desc","func":"singleclick","zoom":'+zoom_p+',"addvcd":"660000","bbox":"'+lon_2+','+lat_2+','+lon_1+','+lat_1+'"}';
                getSpatialData_return = getSpatialData(getSpatialData_parameter);
                //第五步getSpaceData 获取目标矢量，将矢量转换为点线信息
                getSpaceData_parameter = 'elementType='+getSpatialCount_return[0].type+'&id='+getSpatialData_return.list[0].pn_code;
                getSpaceData_return = getSpaceData(getSpaceData_parameter);
                //第六步getDeatil 获取目标属性 获取目标具体属性，并在地图上显示
                getDetail_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","subjectId":"5d731cc2-a388-4a29-ada6-af50ae09d069","pnId":"'+getSpatialData_return.list[0].pn_code+'","elementId":"'+getSpatialCount_return[0].elementId+'"}';
                getDeatil_return = getDeatil(getDetail_parameter);
                //在地图上绘制geojson，多绘制为线性，
                //填充样式,颜色以及透明度，
                if (getSpaceData_return!=0){
                    var polygon_data = getSpaceData_return.smGeometry;
                    var startIndex = 0;
                    var endIndex = 0;
                    if (polygon_data.lastIndexOf('[[[[')==-1){
                        startIndex = polygon_data.lastIndexOf('[[[')+2;
                        endIndex = polygon_data.indexOf(']]]')+1;
                    }else{
                        startIndex = polygon_data.lastIndexOf('[[[[')+3;
                        endIndex = polygon_data.indexOf(']]]]')+1;
                    }
                    var shpString = polygon_data.substring(startIndex,endIndex);//polygon_data.substring(startIndex,endIndex);
                    var shpArrays = shpString.split('],');//分割成单个坐标数组
                    var coordinate = [];
                    var shpArrays_one = '';
                    var shpArrays_one_start = 0;
                    var shpArrays_one_end = 0;
                    for (var i=0;i<shpArrays.length;i++){
                        shpArrays_one_start = shpArrays[i].lastIndexOf('[')+1;
                        shpArrays_one_end = shpArrays[i].lastIndexOf(']');
                        if (shpArrays_one_start!=-1){
                            if (shpArrays_one_end!=-1){
                                shpArrays_one=shpArrays[i].substring(shpArrays_one_start,shpArrays_one_end);
                            }else{
                                shpArrays_one=shpArrays[i].substring(shpArrays_one_start);
                            }
                        }

                        var point = shpArrays_one.split(', ');
                        coordinate[i]=[parseFloat(point[0]),parseFloat(point[1])];

                    }
                    vectorSource.clear();
                    var coordinate_part=[];
                    var coordinate_one=coordinate[0];
                    var coordinate_num=0;
                    //将矢量图划分为小段  防止交叉
                    for (var i=1;i<coordinate.length;i++){
                        if (coordinate_one[0]==coordinate[i][0]){
                            coordinate_part=coordinate.slice(coordinate_num,i+1);
                            var polygon = new ol.geom.LineString(coordinate_part);
                            //polygon.applyTransform(ol.proj.getTransform('EPSG:4490', 'EPSG:3857'));
                            var feature = new ol.Feature(polygon);
                            feature.setStyle(new ol.style.Style({
                                stroke: new ol.style.Stroke({ //边界样式
                                    color: '#FF0000',
                                    width: 3
                                })}));
                            vectorSource.addFeature(feature);
                            coordinate_num=i+1;
                            coordinate_one=coordinate[i+1];
                            i=i+1;
                        }
                    }
                    if (coordinate_num==0){
                        vectorSource.clear();
                        console.log(coordinate);
                        var polygon = new ol.geom.LineString(coordinate);
                        //polygon.applyTransform(ol.proj.getTransform('EPSG:4490', 'EPSG:3857'));
                        var feature = new ol.Feature(polygon);
                        feature.setStyle(new ol.style.Style({
                            stroke: new ol.style.Stroke({ //边界样式
                                color: '#FF0000',
                                width: 3
                            })}));
                        vectorSource.addFeature(feature);
                    }
                }
                //在地图上绘制overlay弹出框
                click_element_location(x,y,lon_3,lat_3,getDeatil_return);
                app_map.loadingProject.close();
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};
const getSpatialCountChannel=(obj,lon_1,lon_3,lat_1,lat_3,lon_2,lat_2,x,y,zoom_p)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: baseUrl + "web/item_list/getSpatialCount", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                getSpatialCount_return  = object.data;
                if (getSpatialCount_return==0){
                    vectorSource.clear();
                    overlay_map_element.setPosition(undefined);
                    app_channel.loadingProject.close();
                    return [];
                }
                //第二步select 获取对象所在图层，特定对象Id
                select_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'"}';
                select_p_return = select_p(select_parameter);
                //第三步getSortList 若存在多个对象，获取对象列表
                getSortList_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'"}';
                getSortList_return = getSortList(getSortList_parameter);
                //第四步getSpatialData 再次获取对象信息，信息较为完善
                getSpatialData_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","location":"POLYGON(('+lon_2+' '+lat_1 +','+lon_1+' '+lat_1+','+lon_1+' '+lat_2+','+lon_2+' '+lat_2+','+lon_2+' '+lat_1+'))","elementType":"'+getSpatialCount_return[0].type+'","elementId":"'+getSpatialCount_return[0].elementId+'","geometryType":"'+getSpatialCount_return[0].geometryType+'","pageIndex":1,"pageSize":10,"layers":[{"elementType":"irr","index":2},{"elementType":"rvlk","index":3},{"elementType":"rswb","index":3},{"elementType":"ggqd","index":12},{"elementType":"gate","index":22}],"sort":"'+getSortList_return[0].esfiledname+'","order":"desc","func":"singleclick","zoom":'+zoom_p+',"addvcd":"660000","bbox":"'+lon_2+','+lat_2+','+lon_1+','+lat_1+'"}';
                getSpatialData_return = getSpatialData(getSpatialData_parameter);
                //第五步getSpaceData 获取目标矢量，将矢量转换为点线信息
                getSpaceData_parameter = 'elementType='+getSpatialCount_return[0].type+'&id='+getSpatialData_return.list[0].pn_code;
                getSpaceData_return = getSpaceData(getSpaceData_parameter);
                //第六步getDeatil 获取目标属性 获取目标具体属性，并在地图上显示
                getDetail_parameter = '{"userId":"f439de16-db47-42aa-938e-e72c203ed5e0","subjectId":"5d731cc2-a388-4a29-ada6-af50ae09d069","pnId":"'+getSpatialData_return.list[0].pn_code+'","elementId":"'+getSpatialCount_return[0].elementId+'"}';
                getDeatil_return = getDeatil(getDetail_parameter);
                //在地图上绘制geojson，多绘制为线性，
                //填充样式,颜色以及透明度，
                if (getSpaceData_return!=0){
                    var polygon_data = getSpaceData_return.smGeometry;
                    var startIndex = 0;
                    var endIndex = 0;
                    if (polygon_data.lastIndexOf('[[[[')==-1){
                        startIndex = polygon_data.lastIndexOf('[[[')+2;
                        endIndex = polygon_data.indexOf(']]]')+1;
                    }else{
                        startIndex = polygon_data.lastIndexOf('[[[[')+3;
                        endIndex = polygon_data.indexOf(']]]]')+1;
                    }
                    var shpString = polygon_data.substring(startIndex,endIndex);//polygon_data.substring(startIndex,endIndex);
                    var shpArrays = shpString.split('],');//分割成单个坐标数组
                    var coordinate = [];
                    var shpArrays_one = '';
                    var shpArrays_one_start = 0;
                    var shpArrays_one_end = 0;
                    for (var i=0;i<shpArrays.length;i++){
                        shpArrays_one_start = shpArrays[i].lastIndexOf('[')+1;
                        shpArrays_one_end = shpArrays[i].lastIndexOf(']');
                        if (shpArrays_one_start!=-1){
                            if (shpArrays_one_end!=-1){
                                shpArrays_one=shpArrays[i].substring(shpArrays_one_start,shpArrays_one_end);
                            }else{
                                shpArrays_one=shpArrays[i].substring(shpArrays_one_start);
                            }
                        }

                        var point = shpArrays_one.split(', ');
                        coordinate[i]=[parseFloat(point[0]),parseFloat(point[1])];

                    }
                    vectorSource.clear();
                    var coordinate_part=[];
                    var coordinate_one=coordinate[0];
                    var coordinate_num=0;
                    //将矢量图划分为小段  防止交叉
                    for (var i=1;i<coordinate.length;i++){
                        if (coordinate_one[0]==coordinate[i][0]){
                            coordinate_part=coordinate.slice(coordinate_num,i+1);
                            var polygon = new ol.geom.LineString(coordinate_part);
                            //polygon.applyTransform(ol.proj.getTransform('EPSG:4490', 'EPSG:3857'));
                            var feature = new ol.Feature(polygon);
                            feature.setStyle(new ol.style.Style({
                                stroke: new ol.style.Stroke({ //边界样式
                                    color: '#FF0000',
                                    width: 3
                                })}));
                            vectorSource.addFeature(feature);
                            coordinate_num=i+1;
                            coordinate_one=coordinate[i+1];
                            i=i+1;
                        }
                    }
                    if (coordinate_num==0){
                        vectorSource.clear();
                        console.log(coordinate);
                        var polygon = new ol.geom.LineString(coordinate);
                        //polygon.applyTransform(ol.proj.getTransform('EPSG:4490', 'EPSG:3857'));
                        var feature = new ol.Feature(polygon);
                        feature.setStyle(new ol.style.Style({
                            stroke: new ol.style.Stroke({ //边界样式
                                color: '#FF0000',
                                width: 3
                            })}));
                        vectorSource.addFeature(feature);
                    }
                }
                //在地图上绘制overlay弹出框
                click_element_location(x,y,lon_3,lat_3,getDeatil_return);
                app_channel.loadingProject.close();
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};

const select_p=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: baseUrl + "web/advanced/select", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                result  = object.data;
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};

const getSortList=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: baseUrl + "web/itemlist/getSortList", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                result  = object.data;
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};

const getSpatialData=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: baseUrl + "web/item_list/getSpatialData", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                result  = object.data;
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};

const getSpaceData=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: baseUrl + "web/item_list/getSpaceDataById?"+obj, //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                result  = object.data;
            }
            else{
                console.log(1);
            }
        }
    });
    return result;
};

const getDeatil=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: baseUrl + "web/itemlist/getDetail", //请求的url地址
        dataType: "json", //返回格式为json
        type: "post", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            if(object.responseMsg == 'success' ){
                result  = object.data;
            }
            else{
                alert(object.responseMsg+'！');
                return [];
            }
        }
    });
    return result;
};

//查询水库下所有渠道
const getQd=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: "waterInfo/getDicByid", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            console.log(object);
            qdInfo = object.data;
            //单个水流方向点
            // var normInfo = [];
            // for (var i=0,j=0;i<qdInfo.length;i++){
            //     if(qdInfo[i].status==1){
            //         normInfo[j] = { "coords": qdInfo[i].lines, "lineStyle": { "color": "rgb(64,158,255)" } };
            //         j++;
            //     }
            // }
            //多个水流方向点
            var qdInfoCut=[];
            for (var i=0,j=0;i<qdInfo.length;i++){
                if (qdInfo[i].status==1){
                    var qdInfoTemp=getNewArray(qdInfo[i].lines,40);
                    for (var m=0;m<qdInfoTemp.length;m++){
                        qdInfoCut[j]=qdInfoTemp[m];
                        j++;
                    }
                }
            }

            var normInfo = [];
            var channelLength=qdInfoCut.length;
            for (var k=0;k<channelLength;k++){
                normInfo[k] = { "coords": qdInfoCut[k], "lineStyle": { "color": "rgb(64,158,255)" } };
            }
            console.log(normInfo);
            var path = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
            option_t = {
                color:['red'],
                series: [
                    // {
                    //     type: 'lines',
                    //     blendMode: 'lighter',
                    //     dimensions: ['value'],
                    //     symbol:['arrow', 'arrow'],
                    //     symbolSize:['10', '10'],
                    //     data: normInfo,
                    //     polyline: true,
                    //     large: true,
                    //     animation:false,
                    //     color:'red',
                    //     lineStyle: {
                    //         type: 'solid',
                    //         width: 3,
                    //         shadowColor: 'rgba(0,0,0,0.61)',
                    //         shadowBlur: 10,
                    //         opacity:1,
                    //
                    //
                    //     }
                    // },
                    {
                        type: 'lines',
                        coordinateSystem: 'geo',
                        polyline: true,
                        data: normInfo,
                        lineStyle: {
                            width: 0
                        },
                        effect: {
                            symbol:'image://./img/chevrons-down.svg',
                            constantSpeed: 27,
                            show: true,
                            trailLength: 0.6,
                            symbolSize: 18,
                            shadowBlur: 5,
                            color:'rgb(64,158,255)',

                        },
                        zlevel: 1
                    },


                ]
            };
            echartslayer.remove();
            //echarts轨迹追踪
            echartslayer = new ol3Echarts(option_t, {
                source: '',
                destination: '',
                hideOnMoving: true,
                forcedRerender: false,
                forcedPrecomposeRerender: false
            });
            echartslayer.appendTo(map);
            echartslayer.setZIndex(1);
            creat_qd();
        }
    });
    return result;
};

//查询水库下所有渠道
const getSz=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: "waterInfo/getRelaByid", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            var szInfo = object.data;
            //添加图标图层
            for (var i=0;i<szInfo.length;i++){
                iconFeature_sz = new ol.Feature({
                    geometry: new ol.geom.Point([szInfo[i].x,szInfo[i].y]),
                    name:szInfo[i].name,
                    stcd:szInfo[i].stcd,
                });
                if(szInfo[i].lx=='水闸'){
                    iconFeature_sz.setStyle(creatMarkSz(iconFeature_sz));
                }else if (szInfo[i].lx=='分水计量点'){
                    iconFeature_sz.setStyle(creatMarkFs(iconFeature_sz));
                }else if (szInfo[i].lx=='灌区测水点'){
                    iconFeature_sz.setStyle(creatMarkCs(iconFeature_sz));
                }else {
                    iconFeature_sz.setStyle(creatMarkSw(iconFeature_sz));
                }

                iconSource_sz.addFeature(iconFeature_sz);
            }
        }
    });
    return result;
};

//查询该人员下辖所有测站
const creatHumanSluice=(obj,iconSourceSluice,iconSourceSluiceText)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';
    var iconFeatureSluice = '';
    var iconFeatureSluiceText = '';
    //添加分水计量点，ol.style是对矢量图层进行设置的
    function creatMarkFs(feature) {
        return new ol.style.Style({
            image: new ol.style.Icon(({
                src: './img/water_resource_lable/fsjld.png',
                scale:0.55,
            })),
        });
    }
    function creatMarkFsText(feature) {
        return new ol.style.Style({
            text: new ol.style.Text({
                font: '12px Calibri,sans-serif',    //字体与大小
                fill: new ol.style.Fill({    //文字填充色
                    color: '#000'
                }),
                stroke: new ol.style.Stroke({    //文字边界宽度与颜色
                    color: '#fff',
                    width: 3
                }),
                textAlign:'center',
                textBaseline:'middle',
                text:feature.get('name'),
                offsetY: -20,
            })
        });
    }

    $.ajax({
        async:true,
        url: "waterInfo/getRelaByid", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            //清除相关图层信息
            iconSourceSluice.clear();
            iconSourceSluiceText.clear();
            var sluiceInfo = object.data;
            //添加图标图层
            for (var i=0;i<sluiceInfo.length;i++){
                iconFeatureSluice = new ol.Feature({
                    geometry: new ol.geom.Point([sluiceInfo[i].x,sluiceInfo[i].y]),
                    name:sluiceInfo[i].name,
                    stcd:sluiceInfo[i].stcd,
                });
                iconFeatureSluiceText = new ol.Feature({
                    geometry: new ol.geom.Point([sluiceInfo[i].x,sluiceInfo[i].y]),
                    name:sluiceInfo[i].name,
                    stcd:sluiceInfo[i].stcd,
                });
                iconFeatureSluice.setStyle(creatMarkFs(iconFeatureSluice));
                iconSourceSluice.addFeature(iconFeatureSluice);
                iconFeatureSluiceText.setStyle(creatMarkFsText(iconFeatureSluiceText));
                iconSourceSluiceText.addFeature(iconFeatureSluiceText);
            }
        }
    });
    return result;
};
//查询一个测站位置
const creatSluiceLocation=(sluiceLong,sluiceLat,sluiceName,iconSourceSluiceOne,iconSourceSluiceTextOne)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var iconFeatureSluiceOne = '';
    var iconFeatureSluiceTextOne = '';
    //添加分水计量点，ol.style是对矢量图层进行设置的
    function creatMarkFs(feature) {
        return new ol.style.Style({
            image: new ol.style.Icon(({
                src: './img/water_resource_lable/fsjld.png',
                scale:0.55,
            })),
        });
    }
    function creatMarkFsText(feature) {
        return new ol.style.Style({
            text: new ol.style.Text({
                font: '12px Calibri,sans-serif',    //字体与大小
                fill: new ol.style.Fill({    //文字填充色
                    color: '#000'
                }),
                stroke: new ol.style.Stroke({    //文字边界宽度与颜色
                    color: '#fff',
                    width: 3
                }),
                textAlign:'center',
                textBaseline:'middle',
                text:feature.get('name'),
                offsetY: -20,
            })
        });
    }
    //清除相关图层信息
    iconSourceSluiceOne.clear();
    iconSourceSluiceTextOne.clear();
    //添加图标图层
    iconFeatureSluiceOne = new ol.Feature({
        geometry: new ol.geom.Point([sluiceLong,sluiceLat]),
        name:sluiceName,
    });
    iconFeatureSluiceTextOne = new ol.Feature({
        geometry: new ol.geom.Point([sluiceLong,sluiceLat]),
        name:sluiceName,
    });
    iconFeatureSluiceOne.setStyle(creatMarkFs(iconFeatureSluiceOne));
    iconSourceSluiceOne.addFeature(iconFeatureSluiceOne);
    iconFeatureSluiceTextOne.setStyle(creatMarkFsText(iconFeatureSluiceTextOne));
    iconSourceSluiceTextOne.addFeature(iconFeatureSluiceTextOne);
};



//获取分水计量点层级关系

const getListFs=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: "waterInfo/getDicTable", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            app_channel.waterSeparationData.splice(0,app_channel.waterSeparationData.length);
            var waterSeparationDataAll = object.data;
            if (waterSeparationDataAll.stcd==null){
                app_channel.waterSeparationData=[];
            }else{
                app_channel.waterSeparationData[0]=waterSeparationDataAll;
                //地图中心位置移动
                var lon_3=move_right(app_channel.waterSeparationData[0].x,app_channel.waterSeparationData[0].y,45);
                var lat_3=move_down(app_channel.waterSeparationData[0].x,app_channel.waterSeparationData[0].y,1200);
                map.getView().animate({
                    duration: 800,
                    center: [lon_3,lat_3],
                },{
                    zoom: 14
                });

            }
            if(app_channel.loadingChannel!=''){
                app_channel.loadingChannel.close();
            }

        }
    });
    return result;
};



//获取测水点测水信息
const getInfoCz=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: "waterInfo/getStcdInfo", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            result = object;
        }
    });
    return result;
};


//获取水利工程信息
const getProjectBase=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:true,
        url: "waterInfo/getInfo", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            var projectBaseDataAll = object.data;
            var projectBaseData = projectBaseDataAll.list;
            app_map.projectData.splice(0,app_map.projectData.length);
            if (projectBaseDataAll.total==0){
                app_map.openNoList();
            }else{
                for (var i=0;i<projectBaseData.length;i++){
                    app_map.projectData[i]={
                        id:projectBaseData[i].gid,
                        name:projectBaseData[i].name,
                        order: (app_map.currentPage-1)*app_map.pageSize+i+1,
                        longitude: projectBaseData[i].x,
                        latitude: projectBaseData[i].y,
                    };
                }
            }
            app_map.totalPage = projectBaseDataAll.total;
            app_map.projectCount =projectBaseDataAll.total;
            if(app_map.loadingInitProject!=''){
                app_map.loadingInitProject.close();
            }

        }
    });
    return result;
};

//获取测站上报信息
const getSeparationDate=(obj)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';

    $.ajax({
        async:false,
        url: "waterInfo/getInfoByTime", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            result = object.data;
        }
    });
    return result;
};



//获取测水点累计水量信息
const getWaterSeparation=(skName,date2)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';
    if (date2==null){
        return ;
    }
    var obj={
        code:skName,
        etime:date2[1],
        stime:date2[0],
    };
    $.ajax({
        async:true,
        url: "waterInfo/getMoniData", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            var waterSeparationData = object.data;
            var maxCount=0;
            //必须得做清空
            app_channel.waterSeparationName.splice(0,app_channel.waterSeparationName.length);
            app_channel.waterSeparationCount.splice(0,app_channel.waterSeparationCount.length);
            app_channel.waterSeparationCode.splice(0,app_channel.waterSeparationCode.length);
            for(var i=0;i<waterSeparationData.length;i++){
                app_channel.waterSeparationName[i]=waterSeparationData[i].ST_NAME;
                app_channel.waterSeparationCount[i]=waterSeparationData[i].total;
                app_channel.waterSeparationCode[i]=waterSeparationData[i].ST_CODE;
                if(parseFloat(waterSeparationData[i].total)>maxCount){
                    maxCount=parseFloat(waterSeparationData[i].total);
                }
            }

            var option2 = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    },
                    // formatter: function (params) {
                    //     let str = params[0].name + "<br />";
                    //     params.forEach((item) => {
                    //         str +=
                    //             '<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:'+item.color+'"></span>' + item.seriesName + " :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp " + item.data + "(万m³)<br />";
                    //     });
                    //     return str;
                    // },
                },
                dataZoom: [
                    {
                        type: 'inside',
                        yAxisIndex: [0],
                        start: 0,
                        end: 100,
                        zoomOnMouseWheel:'shift',
                        moveOnMouseMove:false,
                        moveOnMouseWheel:true,
                        minValueSpan:5,
                        maxValueSpan:14,
                    }
                ],
                grid: {
                    left: '41%',
                    right: '6%',
                    top: '5%',
                    bottom: '0%',
                },
                backgroundColor: 'transparent',
                xAxis: [{
                    show: false,
                }],
                yAxis: {
                    type: 'category',
                    data: app_channel.waterSeparationName,
                    axisLabel: {
                        show: true, //让Y轴数据不显示
                        color:'#fff',
                    },
                    itemStyle: {

                    },
                    axisTick: {
                        show: false, //隐藏Y轴刻度
                    },
                    axisLine: {
                        show: false, //隐藏Y轴线段
                    },
                },
                visualMap: {
                    orient: 'horizontal',
                    top: "-1%",
                    left: 'center',
                    min: 0,
                    max: maxCount,
                    textStyle:{
                        color:'#fff',
                    },
                    text: ['水量('+maxCount+'万m³)', '水量(0万m³)'],
                    // Map the score column to color
                    dimension: 0,
                    inRange: {
                        color: ['#0efcff', '#ff7f00', '#ff0000']
                    }
                },
                series: [
                    //背景色--------------------我是分割线君------------------------------//
                    //
                    // {
                    //     show: true,
                    //     type: 'bar',
                    //     barGap: '-100%',
                    //     barWidth: '50%', //统计条宽度
                    //     itemStyle: {
                    //         normal: {
                    //             color: '#3B4254'
                    //         },
                    //     },
                    //     z: 1,
                    //     // data: grayBar,
                    // },
                    //蓝条--------------------我是分割线君------------------------------//
                    {
                        show: true,
                        name:'累计水量',
                        type: 'bar',
                        stack:'total',
                        emphasis: {
                            focus: 'series'
                        },
                        barMaxWidth: 18, //统计条宽度
                        label: {
                            show:true,
                            textStyle: {
                                color:'#fff',
                            },
                        },
                        data: app_channel.waterSeparationCount,
                    },
                    // {
                    //     show: true,
                    //     type: 'bar',
                    //     name:'当前库容(百万m³)',
                    //     stack:'total',
                    //     label: {
                    //         show: true,
                    //     },
                    //     emphasis: {
                    //         focus: 'series'
                    //     },
                    //     barWidth: '50%', //统计条宽度
                    //     itemStyle: {
                    //         color: '#FA8100',
                    //     },
                    //     data: baifenbi1,
                    // },
                    //数据条--------------------我是分割线君------------------------------//
                    // {
                    //     show: true,
                    //     type: 'bar',
                    //     xAxisIndex: 1, //代表使用第二个X轴刻度!!!!!!!!!!!!!!!!!!!!!!!!
                    //     barGap: '-100%',
                    //     barWidth: '40%', //统计条宽度
                    //     itemStyle: {
                    //         normal: {
                    //             barBorderRadius: 200,
                    //             color: 'transparent'
                    //         },
                    //     },
                    //     label: {
                    //         normal: {
                    //             show: true,
                    //             //label 的position位置可以是top bottom left,right,也可以是固定值
                    //             //在这里需要上下统一对齐,所以用固定值
                    //             position: ["-28%", '5%'],
                    //             rich: { //富文本
                    //                 color: { //自定义颜色
                    //                     color: '#1BC5CC',
                    //                     fontSize: 12
                    //                 },
                    //                 value: xingm,
                    //                 start1: {
                    //                 },
                    //
                    //             },
                    //             formatter: function (data) {
                    //                 //富文本固定格式{colorName|这里填你想要写的内容}
                    //                 return '{start1|}{color|' + xingm[data.dataIndex] + '}'
                    //
                    //             },
                    //         }
                    //     },
                    //     data: zongjine
                    // }

                ]
            };
            HYChart2.clear();
            HYChart2.setOption(option2);
            HYChart2.getZr().on('click', (params) => {
                const pointInPixel = [params.offsetX, params.offsetY];
                //点击第几个柱子
                let index;
                if (HYChart2.containPixel('grid', pointInPixel)) {
                    index = HYChart2.convertFromPixel({seriesIndex: 0}, pointInPixel)[1];
                }
                console.log(index);
                if(index==undefined){
                    return;
                }
                app_channel.dialogTableVisible=true;
                app_channel.dialogTitle = app_channel.waterSeparationName[index];
                app_channel.waterSeparationId=app_channel.waterSeparationCode[index];

            })
        }
    });
    return result;
};

//获取龙口测水点累计水量
const getWaterSeparationCapital=(skName,date2)=>{
    // obj 是一个对象：
    // 具体如下：{
    //  awDtEnd:''  // 截至时间
    //  awDtStart:''  // 开始时间
    // }
    var  result = '0';
    if (date2==null){
        return ;
    }
    var obj={
        code:skName,
        etime:date2[1],
        stime:date2[0],
    };
    $.ajax({
        async:true,
        url: "waterInfo/getSumDataByDate", //请求的url地址
        dataType: "json", //返回格式为json
        type: "get", //请求方式
        data:obj,
        contentType:"application/json", //dataType设置你收到服务器数据的格式
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", token);
        // },
        success: function (object) {
            var waterSeparationCapitalData = object.data;
            var countAdd=0;
            //必须得做清空
            app_channel.waterSeparationCapitalDate.splice(0,app_channel.waterSeparationCapitalDate.length);
            app_channel.waterSeparationCapitalCount.splice(0,app_channel.waterSeparationCapitalCount.length);
            for(var i=0;i<waterSeparationCapitalData.length;i++){
                app_channel.waterSeparationCapitalDate[i]=waterSeparationCapitalData[i].tm;
                countAdd=countAdd+waterSeparationCapitalData[i].stW;
                app_channel.waterSeparationCapitalCount[i]=countAdd;
            }
            countAdd=Math.floor(countAdd*1.1);

            var option3 = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    },
                    formatter: function (params) {
                        let str =date2[0]+"至"+params[0].name + "<br />";
                        params.forEach((item) => {
                            str +=
                                '<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:'+item.color+'"></span>' + item.seriesName + " :&nbsp&nbsp&nbsp&nbsp&nbsp" + item.data.toFixed(2) + "(万m³)<br />";
                        });
                        return str;
                    },
                },
                dataZoom: [
                    {
                        type: 'inside',
                        xAxisIndex: [0],
                        start: 0,
                        end: 100,
                        zoomOnMouseWheel:'shift',
                        moveOnMouseMove:false,
                        moveOnMouseWheel:true,
                        minValueSpan:5,
                        maxValueSpan:366,
                    }
                ],
                visualMap: {
                    orient: 'horizontal',
                    top: "-1%",
                    left: 'center',
                    min: 0,
                    max: countAdd,
                    textStyle:{
                        color:'#fff',
                    },
                    text: ['水量('+countAdd+')', '水量(0)'],
                    // Map the score column to color
                    dimension: 1,
                    inRange: {
                        color: ['#0efcff', '#ff7f00', '#ff0000']
                    }
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        data: app_channel.waterSeparationCapitalDate,
                        axisLabel: {
                            textStyle: {
                                color: '#fff',
                                // opacity: 0.1,
                            }
                        },
                        "axisTick": {       //y轴刻度线
                            "show": false
                        },
                        "axisLine": {       //y轴
                            "show": false,
                        },
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        scale: true,
                        name: "水量/万m³",
                        nameTextStyle: {
                            color: '#fff',
                        },
                        max: countAdd,
                        min: 0,
                        boundaryGap: [0.2, 0.2],
                        "axisTick": {       //y轴刻度线
                            "show": false
                        },
                        "axisLine": {       //y轴
                            "show": false,
                        },
                        axisLabel: {
                            textStyle: {
                                color: '#fff',
                                // opacity: 0.1,
                            }
                        },
                        splitLine: {  //决定是否显示坐标中网格
                            show: true,
                            lineStyle: {
                                color: ['#fff'],
                                opacity: 0.2
                            }
                        },
                    },
                ],
                grid: {
                    left: '3%',
                    right: '4%',
                    top: '25%',
                    bottom: '10%',
                    containLabel: true
                },
                series: [
                    {
                        name: '累计分水量',
                        type: 'line',
                        stack:'total',
                        smooth: true,
                        emphasis: {
                            focus: 'series'
                        },
                        data: app_channel.waterSeparationCapitalCount,
                    },
                ]
            };
            HYChart3.clear();
            HYChart3.setOption(option3);

        }
    });
    return result;
};


